package top.minuy.subject.leetcode._303;
/**
 * @author Minuy
 * @time 19:46
 * @date 2021/10/4
 */
public class NumArray2 {
    int[] sums;
    public NumArray2(int[] nums) {
        sums = new int[nums.length+1];
        sums[0] = 0;
        for (int i=1;i<sums.length;i++){
            sums[i] = sums[i-1]+nums[i-1];
        }
    }

    public int sumRange(int left, int right) {
        return sums[right+1] - sums[left];
    }
}
